//
//  ZHelpContentController.m
//  Zlottery
//
//  Created by HuaYingJiTuan on 16/1/12.
//  Copyright © 2016年 张庆庆. All rights reserved.
//

#import "ZHelpContentController.h"
#import "ZHelp.h"
@interface ZHelpContentController ()<UIWebViewDelegate>
@property (nonatomic, weak) UIWebView *webView;
@end

@implementation ZHelpContentController

- (void)loadView{
    UIWebView *webView = [[UIWebView alloc]init];
    self.webView = webView;
    webView.frame = [UIScreen mainScreen].bounds;
    self.view = webView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSString *path = [[NSBundle mainBundle]pathForResource:self.help.html ofType:nil];
    NSURL *url = [[NSURL alloc]initWithString:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    
    //等待网页加载完成 执行JavaScript
    self.webView.delegate = self;
    [self.webView loadRequest:request];
}

//网页加载完成
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    if (self.help.id) {
        [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.location.href='#%@'",self.help.id]];
    }
}
@end
